package com.bp.hearthealth.pulse.lnapps.bp_ui.bp_fragment.bp_tracker.tracker

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel

class BpTrackerViewModel(private val savedStateHandle: SavedStateHandle) : ViewModel() {

    private val HOME_PAGE_INDEX = "tracker_page_index"
    private val mLiveData = MutableLiveData<Int>()

    fun getCurrentName(): LiveData<Int> {
        if (mLiveData.value == null) {
            val index = savedStateHandle.get<Int>(HOME_PAGE_INDEX) ?: 0
            mLiveData.postValue(index)
        }
        return mLiveData
    }

    fun saveSelect(selectIndex: Int) {
        savedStateHandle[HOME_PAGE_INDEX] = selectIndex
    }
}